<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/form_validate.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:15 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>文章添加</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__ADMIN__css/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN__css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__ADMIN__css/animate.min.css" rel="stylesheet">
    <link href="__ADMIN__css/style.min.css" rel="stylesheet">
    <link href="__ADMIN__js/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/switchery/switchery.css" rel="stylesheet">
    <style>
        .form-control{
            margin-top:10px;
        }
        .a{
            border:1px solid white;
        }
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加文章</h5>
                </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" action="{:U('single/save')}" method="post" name="forma" id="forma"  enctype="multipart/form-data">
                        <input type="hidden" name="id" value="{$listinfo.id}" />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">标题：</label>
                                <div class="col-sm-8">
                                    <input id="title" name="title" class="form-control" type="text" value="{$listinfo.title}">
                                </div>
                            </div>
                            <div>
                                <label class="col-sm-3 control-label">文章内容：</label>
                                <div class="col-sm-8">
                                    <!-- 加载编辑器的容器 -->
                                    <script id="container" name="content" type="text/plain">{$listinfo.content}</script>
                                    <!-- 配置文件 -->
                                    <script type="text/javascript" src="__ADMIN__/editor/ueditor.config.js"></script>
                                    <!-- 编辑器源码文件 -->
                                    <script type="text/javascript" src="__ADMIN__/editor/ueditor.all.js"></script>
                                    <!-- 实例化编辑器 -->
                                    <script type="text/javascript">
                                        var ue = UE.getEditor('container');
                                    </script>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">图片：</label>
                                <div class="col-sm-8">
                                    <input id="img" name="img" class="form-control a" type="file" value="{$listinfo.img}" data-img="{$listinfo.img}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">关键词：</label>
                                <div class="col-sm-8">
                                    <input id="keyword" name="keyword" class="form-control" type="text" value="{$listinfo.keyword}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">状态：</label>
                                <div class="col-sm-8">
                                    <input type="checkbox" value="1" name="status" id="status" class="js-switch form-control" checked <if condition="$listinfo['status'] eq 1"> checked</if>>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                    <button class="btn btn-white" type="reset" onclick="history.go(-1)">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
            </div>
        </div>
    </div>
<script src="__ADMIN__js/jquery.min.js"></script>
<script src="__ADMIN__js/bootstrap.min.js"></script>
<script src="__ADMIN__js/plugins/layer/layer.min.js"></script>
<script src="__ADMIN__js/plugins/switchery/switchery.js"></script>
<script src="__ADMIN__js/plugins/validate/jquery.validate.min.js"></script>
<script src="__ADMIN__js/plugins/validate/messages_zh.min.js"></script>
<script src="__ADMIN__js/common.js"></script>
    <script>
    //表单验证自定义检测方法
    $(document).ready(function(){
        $('#forma').validate({
            rules: {
                title: {
                    required: true
                },
                content: {
                    required: true
                },
                keyword: {
                    required: true
                }
            },
            messages: {
                title: "请输入标题名",
                content: "请输入文章内容",
                keyword:"请输入关键词"
            },
            submitHandler: function(form){
                //通过ajax将整个form表单提交
                var forma = new  FormData(document.getElementById('forma'));
                $.ajax({
                        url:$(form).attr('action'),
                        type:'post',
                        dataType:'json',
                        data:forma,
                        cache: false,
                        processData: false,
                        contentType: false,
                        success:function(data){
                           if(data.status < 1){
                               common.error(data.msg);
                           }else{
                                common.success(data.msg,"{:U("single/index")}");
                           }
                        }
                });
            }
        });
        //开关按钮实例化
         var elem = document.querySelector('.js-switch');
        var switchery = new Switchery(elem, { });


    })
</script>
</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/form_validate.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:16 GMT -->
</html>
